<template>
  <div class="bg">
    <div class="top">
      <div class="topContent">
        <div class="logo">EduPanda</div>
        <div class="search">
          <el-input placeholder="输入关键词" style="width: 500px">
            <template #append>
              <el-button :icon="Search" />
            </template>
          </el-input>
        </div>
        <div class="logout" style="cursor: pointer" @click="logout">
          Log Out
        </div>
      </div>
    </div>
    <div class="rightBar">
      <div @click="goHome">Home</div>
      <div>Go Top</div>
    </div>
    <div class="detailContent">
      <div class="selectProvince">
        <div
          class="letter"
          v-for="(letter, index) in letterList"
          :key="letter.name"
        >
          {{ letter.name }}
        </div>
      </div>
      <el-tabs
        type="border-card"
        style="width: 80%; margin: 0 auto; margin-top: 20px"
      >
        <el-tab-pane label="北京">北京</el-tab-pane>
        <el-tab-pane label="上海">上海</el-tab-pane>
        <el-tab-pane label="成都">成都</el-tab-pane>
        <el-tab-pane label="武汉">武汉</el-tab-pane>
        <el-tab-pane label="厦门">厦门</el-tab-pane>
        <el-tab-pane label="重庆">重庆</el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { Search } from "@element-plus/icons-vue";
import { useUserStore } from "@/stores/user";
let letterList = ref([
  { name: "A" },
  { name: "B" },
  { name: "C" },
  { name: "D" },
  { name: "E" },
  { name: "F" },
  { name: "G" },
  { name: "H" },
  { name: "I" },
  { name: "J" },
  { name: "K" },
  { name: "L" },
  { name: "M" },
  { name: "N" },
  { name: "O" },
  { name: "P" },
  { name: "Q" },
  { name: "R" },
  { name: "S" },
  { name: "T" },
  { name: "U" },
  { name: "V" },
  { name: "W" },
  { name: "X" },
  { name: "Y" },
  { name: "Z" },
]);
const $router = useRouter();
const $route = useRoute();
const userStore = useUserStore();
const goHome = () => {
  $router.replace("/");
};
const logout = async () => {
  await userStore.userLogout();
  $router.replace({ path: "/login", query: { redirect: $route.path } });
};
</script>

<style scoped lang="scss">
.bg {
  width: 100%;
  height: 100vh;
  background-color: #f5f5f5;
  .top {
    width: 100%;
    background-color: #fff;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e3e3e3;
    position: fixed;
    top: 0;
    left: 0;
    .topContent {
      width: 80%;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
  }
  .rightBar {
    background-color: #fff;
    width: 100px;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    border-left: 1px solid #e3e3e3;
    padding-top: 70px;
    z-index: 999;
    div {
      width: 100%;
      height: 100px;
      border-top: 1px solid #e3e3e3;
      border-bottom: 1px solid #e3e3e3;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 10px;
      transition: all 0.5s;
      cursor: pointer;
    }
    div:hover {
      color: #0077c2;
    }
  }
  .detailContent {
    margin-top: 70px;
    padding-top: 30px;
    width: 100%;
    .selectProvince {
      width: 80%;
      margin: 0 auto;
      display: flex;
      align-items: center;
      .letter {
        width: 40px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #0077c2;
        color: #fff;
        font-weight: bold;
        margin-right: 6px;
        border-radius: 5px;
        transition: all 0.5s;
        cursor: pointer;
      }
      .letter:hover {
        background-color: #59a5f5;
      }
    }
  }
}
</style>